workspace "KDEngine"
	configurations { "Debug", "Release" }
	architecture "x64"
	startproject "Kuadunut"

	outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
	-- 引入premake5.lua文件
	IncludeDir = {}
	IncludeDir["GLFW"] = "KDEngine/vendor/GLFW/include"
	IncludeDir["Glad"] = "KDEngine/vendor/Glad/include"
	IncludeDir["ImGui"] = "KDEngine/vendor/ImGui"
	IncludeDir["glm"] = "KDEngine/vendor/glm"
	IncludeDir["stb_image"] = "KDEngine/vendor/stb_image"
	IncludeDir["entt"] = "KDEngine/vendor/entt/include"
	IncludeDir["yaml_cpp"] = "KDEngine/vendor/yaml-cpp/include"
	IncludeDir["ImGuizmo"] = "KDEngine/vendor/ImGuizmo"

	group "Dependencies"
		include "KDEngine/vendor/GLFW"
		include "KDEngine/vendor/Glad"
		include "KDEngine/vendor/ImGui"
		include "KDEngine/vendor/yaml-cpp"
	group ""

	pchheader "kdpch.h"
	pchsource "KDEngine/src/kdpch.cpp"

project "KDEngine"
	location "KDEngine"
	kind "StaticLib"
	language "C++"
	cppdialect "C++17"
	staticruntime "on"

	targetdir ("bin/" .. outputdir .. "/%{prj.name}")
	objdir ("bin-int/" .. outputdir .. "/%{prj.name}")

	files
	{
		"%{prj.name}/src/**.h",
		"%{prj.name}/src/**.cpp",
		"%{prj.name}/vendor/stb_image/**.h",
		"%{prj.name}/vendor/stb_image/**.cpp",
		"%{prj.name}/vendor/glm/glm/**.hpp",
		"%{prj.name}/vendor/glm/glm/**.inl",

		"%{prj.name}/vendor/ImGuizmo/ImGuizmo.h",
		"%{prj.name}/vendor/ImGuizmo/ImGuizmo.cpp"
	}

	defines
	{
		"_CRT_SECURE_NO_WARNINGS"
	}

	includedirs
	{
		"%{prj.name}/src",
		"%{prj.name}/vendor/spdlog/include",
		"%{IncludeDir.GLFW}",
		"%{IncludeDir.Glad}",
		"%{IncludeDir.ImGui}",
		"%{IncludeDir.glm}",
		"%{IncludeDir.stb_image}",
		"%{IncludeDir.entt}",
		"%{IncludeDir.yaml_cpp}",
		"%{IncludeDir.ImGuizmo}"
	}

	-- 引用库模块
	links
	{
		"GLFW",
		"Glad",
		"ImGui",
		"yaml-cpp",
		"opengl32.lib"
	}

	filter  "files:vendor/ImGuizmo/**.cpp"
		flags { "NOPCH" }

	filter { "system:windows", "action:vs*" }
		systemversion "latest"
		buildoptions ("/utf-8")

		defines
		{
			"KD_PLATFORM_WINDOWS",
			"GLFW_INCLUDE_NONE"
		}

	filter "configurations:Debug"
		defines "KD_DEBUG"
		runtime "Debug"
		symbols "on"

	filter "configurations:Release"
		defines "KD_RELEASE"
		runtime "Release"
		optimize "on"

    filter "action:vs*"

project "Kuadunut"
	location "Kuadunut"
	kind "ConsoleApp"
	language "C++"
	cppdialect "C++17"
	staticruntime "on"
			
	targetdir ("bin/" .. outputdir .. "/%{prj.name}")
	objdir ("bin-int/" .. outputdir .. "/%{prj.name}")

	files
	{
		"%{prj.name}/src/**.h",
		"%{prj.name}/src/**.cpp"
	}

	includedirs
	{
		"KDEngine/src",
		"KDEngine/vendor/spdlog/include",
		"KDEngine/vendor",
		"%{IncludeDir.glm}",
		"%{IncludeDir.entt}",
		"%{IncludeDir.ImGuizmo}"
	}

	links
	{
		"KDEngine"
	}

	filter { "system:windows", "action:vs*" }
		systemversion "latest"
		buildoptions ("/utf-8")

		defines
		{
			"KD_PLATFORM_WINDOWS"
		}

	filter "configurations:Debug"
		defines "KD_DEBUG"
		runtime "Debug"
		symbols "on"

	filter "configurations:Release"
		defines "KD_RELEASE"
		runtime "Release"
		optimize "on"	
		
project "Sandbox"
	location "Sandbox"
	kind "ConsoleApp"
	language "C++"
	cppdialect "C++17"
	staticruntime "on"
			
	targetdir ("bin/" .. outputdir .. "/%{prj.name}")
	objdir ("bin-int/" .. outputdir .. "/%{prj.name}")

	files
	{
		"%{prj.name}/src/**.h",
		"%{prj.name}/src/**.cpp"
	}

	includedirs
	{
		"KDEngine/src",
		"KDEngine/vendor/spdlog/include",
		"KDEngine/vendor",
		"%{IncludeDir.glm}",
		"%{IncludeDir.entt}"
	}

	links
	{
		"KDEngine"
	}

	filter { "system:windows", "action:vs*" }
		systemversion "latest"
		buildoptions ("/utf-8")

		defines
		{
			"KD_PLATFORM_WINDOWS"
		}

	filter "configurations:Debug"
		defines "KD_DEBUG"
		runtime "Debug"
		symbols "on"

	filter "configurations:Release"
		defines "KD_RELEASE"
		runtime "Release"
		optimize "on"		
